import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
    state:
    {
        count: 10,
        token: '',
        userInfo: {}
    },
    mutations:
    {
        //set
        SET_TOKEN: (state, token) =>
        {
            state.token = token
            localStorage.setItem("token", token)
        },
        SET_USERINFO:(state, userInfo) =>
        {
            state.userInfo = userInfo
            // sessionStorage 不能存对象，需要对JSON序列化
            sessionStorage.setItem("userInfo", JSON.stringify(userInfo))
        },
        REMO
    },
    actions:
    {
        //get

    }
})